#include "CalendarManager.h"

CalendarManager::CalendarManager() {
}

CalendarManager::CalendarManager(vector<Calendar>& calendars) {
    this->calendars = calendars;
}

CalendarManager::CalendarManager(CalendarManager& copied) {
    this->calendars = copied.calendars;
}

CalendarManager& CalendarManager::operator=(CalendarManager& copied) {
    this->calendars = copied.calendars;
    return *this;
}

CalendarManager::~CalendarManager() {
    calendars.clear();
}

bool CalendarManager::IsExistCalendar(long entryNo) {
    bool result = false;
    int i;
    for (i = 0; i < calendars.size(); i++) {
        if (calendars[i].GetEntryNo() == entryNo) {
            result = true;
            break;
        }
    }
    return result;
}

void CalendarManager::DeleteCalendar(long entryNo) {
    int i;
    for (i = 0; i < calendars.size(); i++) {
        if (calendars[i].GetEntryNo() == entryNo) {
            calendars.erase(calendars.begin() + i);
            break;
        }
    }
}

Calendar& CalendarManager::GetCalendar(long entryNo) {
    int i;
    for (i = 0; i < calendars.size(); i++) {
        if (calendars[i].GetEntryNo() == entryNo) {
            return calendars[i];
        }
    }
    
}

void CalendarManager::AddCalendar(Calendar& calendar) {
    calendars.push_back(calendar);
}

void CalendarManager::SetCalendars(vector<Calendar>& _calendars) {
    calendars.clear();
    int i;
    for (i = 0; i < _calendars.size(); i++) {
        calendars.push_back(_calendars[i]);
    }
}

vector<Calendar>& CalendarManager::GetCalendars() {
    return calendars;
}
